package com.ys.fmms.service.impl;

import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ys.fmms.listener.ExcelListener;
import com.ys.fmms.mapper.DataDisplayMapper;
import com.ys.fmms.pojo.DataDisplay;
import com.ys.fmms.service.DataDisplayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.InputStream;
import java.util.List;

@Transactional
@Service(value = "dataDisplayServiceImpl")
public class DataDisplayServiceImpl extends ServiceImpl<DataDisplayMapper, DataDisplay> implements DataDisplayService {
    @Autowired
    private DataDisplayMapper dataDisplayMapper;

    @Override
    public List<DataDisplay> getList() {
        List<DataDisplay> dataDisplayList = baseMapper.getList();
        return dataDisplayList;
    }

    @Override
    public void uploadData(InputStream inputStream) {
        EasyExcel.read(inputStream, DataDisplay.class, new ExcelListener(dataDisplayMapper)).sheet().doRead();
    }
}
